package cn.aspart.api_logger.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CommonsRequestLoggingFilter;

@Configuration
public class WebConfig {

    @Bean
    public CommonsRequestLoggingFilter loggingFilter() {
        ApiLogger apiLogger = new ApiLogger();
        apiLogger.setIncludeQueryString(true);
        apiLogger.setIncludePayload(true);
        apiLogger.setIncludeHeaders(false);
        apiLogger.setMaxPayloadLength(10000);
        apiLogger.setBeforeMessagePrefix("[api request] --> ");
        apiLogger.setBeforeMessageSuffix("  <-- request end");
        apiLogger.setAfterMessagePrefix("[request payload] --> ");
        apiLogger.setAfterMessageSuffix("  <-- payload end");
        return apiLogger;
    }

}
